package VacationHomework.LeetCode;

public class Num374 extends GuessGame {
    public int guessNumber(int n) {

        int left = 1;
        int right = n;
        while (left < right) {
            long tmp = (long) left + right >> 1;//防止left+right值超过int的最大范围 先用long存储再转为int
            int mid = (int) tmp;
            if (guess(mid) <=0) {
                right = mid;
            }else{
                left = mid + 1;
            }
        }
        return left;
    }
}
